﻿using System;
using System.Collections.Generic;
using System.Reflection;

namespace T.FAS.Action.Dev.Dao
{
    class DaoServiceExtension
    {
        public static Dictionary<string, PropertyInfo> GetAllColumns<T>(Dictionary<string, PropertyInfo> mapping)
        {
            if (mapping.ContainsKey("MeteDataID"))
                mapping.Remove("MeteDataID");

            if (mapping.ContainsKey("MetaDataCode"))
                mapping.Remove("MetaDataCode");

            if (mapping.ContainsKey("MetaDataName"))
                mapping.Remove("MetaDataName");

            if (mapping.ContainsKey("MetaData"))
                mapping.Remove("MetaData");
            if (mapping.ContainsKey("CurrentVersion"))
                mapping.Remove("CurrentVersion");

            if (mapping.ContainsKey("CompatibleMinVersion"))
                mapping.Remove("CompatibleMinVersion");

            if (mapping.ContainsKey("EngineVersion"))
                mapping.Remove("EngineVersion");           

            return mapping;

            var type = typeof(T);
            var prop = type.GetProperty("MeteDataID");
            if (prop != null && !mapping.ContainsKey("MeteDataID"))
                mapping.Add("MeteDataID", prop);

            var propMetaDataCode = type.GetProperty("MetaDataCode");
            if (propMetaDataCode != null && !mapping.ContainsKey("MetaDataCode"))
                mapping.Add("MetaDataCode", propMetaDataCode);

            var propMetaDataName = type.GetProperty("MetaDataName");
            if (propMetaDataName != null && !mapping.ContainsKey("MetaDataName"))
                mapping.Add("MetaDataName", propMetaDataName);

            var propCreateTime = type.GetProperty("CreateTime");
            if (propCreateTime != null && !mapping.ContainsKey("CreateTime"))
                mapping.Add("CreateTime", propCreateTime);

            var propCreator = type.GetProperty("Creator");
            if (propCreator != null && !mapping.ContainsKey("Creator"))
                mapping.Add("Creator", propCreator);

            var propLastModifyTime = type.GetProperty("LastModifyTime");
            if (propLastModifyTime != null && !mapping.ContainsKey("LastModifyTime"))
                mapping.Add("LastModifyTime", propLastModifyTime);

            var propLastModifier = type.GetProperty("LastModifier");
            if (propLastModifier != null && !mapping.ContainsKey("LastModifier"))
                mapping.Add("LastModifier", propLastModifier);

            return mapping;
        }
    }
}
